package com.tianji.learning.controller;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.query.QuestionAdminPageQuery;
import com.tianji.learning.domain.vo.QuestionAdminVO;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/questions")
@Api(tags = "互动问答相关接口")
@RequiredArgsConstructor
public class InteractionQuestionAdminController {

    private final IInteractionQuestionService questionService;

    @ApiOperation("管理端分页查询互动问题")
    @GetMapping("page")
    public PageDTO<QuestionAdminVO> queryQuestionPageAdmin(QuestionAdminPageQuery query){
        return questionService.queryQuestionPageAdmin(query);
    }
    /**
     * Restful风格，显示/隐藏问题
     *
     * @param id     问题id
     * @param hidden 问题0显示/1隐藏
     * @return  是否成功
     */
    @ApiOperation("显示/隐藏问题")
    @PutMapping("/{id}/hidden/{hidden}")
    public boolean updateHiddenById(@PathVariable("id") Long id,
                                    @PathVariable("hidden") Boolean hidden) {
        return questionService.updateHiddenById(id, hidden);
    }
    /**
     * 管理端互动问题详情
     */
    @ApiOperation("管理端互动问题详情")
    @GetMapping("/{id}")
    public QuestionAdminVO detail(@PathVariable("id") Long id) {
        return questionService.detailAdmin(id);
    }
}
